package pojo;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author jlj
 * @Date 2021/3/22 9:36
 * @Description
 * @Modified
 */
//@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TblScene {
    private String sceneName;
    private String sceneId;
    private String sceneDescription;

    @JacksonXmlElementWrapper(localName = "layers")
    @JacksonXmlProperty(localName = "layer")
    private List<Layer> layersList=new ArrayList<>();

//    public List<Layer> getLayers(){
//        if (layersList==null) {
//            return new ArrayList<Layer>();
//        }else {
//            return layersList;
//        }
//    }

    public void addLayer(String dataUrl,String layerName){
        Layer perLayer=new Layer();
        perLayer.setLayerDataUrl(dataUrl);
        perLayer.setLayerName(layerName);
        this.layersList.add(perLayer);
    }

    @Data
    @JacksonXmlRootElement(localName = "layer")
    private class Layer{

        @JacksonXmlProperty(localName = "dataUrl")
        private String layerDataUrl;

        @JacksonXmlProperty(localName = "layerName")
        private String layerName;
    }

}
